// components/remark-input/remark-input.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        remarkName: String,
    },

    /**
     * 组件的初始数据
     */
    data: {
        contentValue: '',
        btuBottom: ''
    },
    lifetimes: {
        attached: function() {
            var _that = this
            wx.getSystemInfo({
                success: function(res) {
                    //model中包含着设备信息
                    var model = res.model;
                    if (model.search('iPhone X') != -1) {
                        _that.setData({
                            btuBottom: 34
                        });
                    }
                }
            })
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        contentInput: function(e) {
            this.setData({
                contentValue: e.detail.value
            });
            this.issue(e.detail.value)
        },
        //评论内容审核/提交
        issue(e) {
            let _that = this
            if (!e) {
                console.log("请输入评论内容！");
                return;
            }
            wx.showLoading({
                title: '加载中...'
            });
            wx.cloud.callFunction({
                name: 'checkContent',
                data: {
                    content: e
                },
                success(res) {
                    if (res.result.errCode == '87014') {
                        wx.showToast({
                            title: "内容违规，请重新编辑",
                            icon: "none",
                            duration: 1500
                        });
                    } else {
                        wx.showToast({
                            title: "评论成功",
                            icon: "success",
                            duration: 1500
                        });
                        _that.setData({
                            contentValue:''
                        })
                    }
                },
                fail(res) {
                    console.log(res)
                }
            })
        }
    },
})